<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%user}}".
 *
 * @property int $id
 * @property string|null $username 用户名
 * @property string|null $email 邮箱
 * @property string $password 密码
 * @property string|null $pay_password 支付密码
 * @property string|null $pwd
 * @property string|null $pay_pwd
 * @property string|null $phone 手机号(11位)
 * @property string $auth_key
 * @property string|null $avatar
 * @property string|null $nickname
 * @property int $status 10正常
 * @property int $created_at
 * @property int|null $updated_at
 * @property int|null $deleted_at
 * @property string $token
 * @property string $key
 * @property int|null $is_admin_super 是否后台超级用户
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['username', 'email', 'password', 'pay_password', 'pwd', 'pay_pwd', 'phone', 'auth_key', 'avatar', 'nickname', 'status', 'created_at', 'updated_at', 'deleted_at', 'token', 'key', 'is_admin_super'], 'trim'],
            [['password', 'auth_key', 'created_at', 'token', 'key'], 'required'],
            [['status', 'created_at', 'updated_at', 'deleted_at', 'is_admin_super'], 'integer'],
            [['username'], 'string', 'max' => 100],
            [['email', 'avatar', 'nickname'], 'string', 'max' => 180],
            [['password', 'pay_password', 'auth_key', 'token', 'key'], 'string', 'max' => 32],
            [['pwd', 'pay_pwd'], 'string', 'max' => 200],
            [['phone'], 'string', 'max' => 11],
            [['username', 'email', 'pay_password', 'pwd', 'pay_pwd', 'phone', 'avatar', 'nickname', 'updated_at', 'deleted_at'], 'default', 'value' => null],
            [['status'], 'default', 'value' => 10],
            [['is_admin_super'], 'default', 'value' => 0],
            [['token'], 'unique'],
            [['username'], 'unique'],
            [['email'], 'unique'],
            [['phone'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'username' => Yii::t('app', '用户名'),
            'email' => Yii::t('app', '邮箱'),
            'password' => Yii::t('app', '密码'),
            'pay_password' => Yii::t('app', '支付密码'),
            'pwd' => Yii::t('app', 'Pwd'),
            'pay_pwd' => Yii::t('app', 'Pay Pwd'),
            'phone' => Yii::t('app', '手机号(11位)'),
            'auth_key' => Yii::t('app', 'Auth Key'),
            'avatar' => Yii::t('app', 'Avatar'),
            'nickname' => Yii::t('app', 'Nickname'),
            'status' => Yii::t('app', '10正常'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'deleted_at' => Yii::t('app', 'Deleted At'),
            'token' => Yii::t('app', 'Token'),
            'key' => Yii::t('app', 'Key'),
            'is_admin_super' => Yii::t('app', '是否后台超级用户'),
        ];
    }
}
